package site.xuxingcan.messageclient;

import android.content.Context;
import android.content.SharedPreferences;

public class SharedPreferenceUtil {
    private static volatile SharedPreferenceUtil instance = null;

    public static SharedPreferenceUtil getInstance(Context context) {
        if (instance == null) {
            synchronized (SharedPreferenceUtil.class) {
                if (instance == null) {
                    instance = new SharedPreferenceUtil(context);
                }
            }
        }
        return instance;
    }

    private SharedPreferences mSharedPreferences;

    private SharedPreferenceUtil(Context context) {
        mSharedPreferences = context.getSharedPreferences("default", Context.MODE_PRIVATE);
    }

    public String getIp() {
        return mSharedPreferences.getString("IP", null);
    }

    public void setIp(String s) {
        mSharedPreferences.edit().putString("IP", s).apply();
    }

    public String getPort() {
        return mSharedPreferences.getString("PORT", null);
    }

    public void setPort(String s) {
        mSharedPreferences.edit().putString("PORT", s).apply();
    }

    public String getMessage() {
        return mSharedPreferences.getString("Message", null);
    }

    public void setMessage(String s) {
        mSharedPreferences.edit().putString("Message", s).apply();
    }

    public String getName() {
        return mSharedPreferences.getString("Name", null);
    }

    public void setName(String s) {
        mSharedPreferences.edit().putString("Name", s).apply();
    }

    public String getPWD() {
        return mSharedPreferences.getString("PWD", null);
    }

    public void setPWD(String s) {
        mSharedPreferences.edit().putString("PWD", s).apply();
    }

}
